<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let obj = {
            name: "张可",
            sex: "女"
        }
        console.log(Object.keys(obj).length);
        obj[Symbol.iterator] = function () {
            let index=0;
            return {
                next:function(){
                    if(index < Object.keys(obj).length){
                        return { value: Object.keys(obj)[index++], done: false }
                    }else{
                        return { value: undefined, done: true }
                    }
                }
            }
        }
        let iter=obj[Symbol.iterator]();
        console.log(iter.next());
        console.log(iter.next());
        console.log(iter.next());
        
    </script>
</body>

</html>